package com.nbicc.service.modular.dp.webpointvaluetype.service;

import com.nbicc.core.common.RequestPageObj;
import com.nbicc.core.common.ResponseUtil;
import com.nbicc.core.utils.ToolUtils;
import com.nbicc.db.modular.dp.webpointvaluetype.mapper.WebPointValueTypeMapper;
import com.nbicc.db.modular.dp.webpointvaluetype.model.WebPointValueType;
import com.nbicc.service.parent.serivce.BaseSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: lilingyan
 */
@Service
public class WebPointValueTypeService extends BaseSerivce {

    @Autowired
    private WebPointValueTypeMapper webPointValueTypeMapper;

    public ResponseEntity<ModelMap> selectById(String id) {
        return ResponseUtil.ok(webPointValueTypeMapper.selectById(id));
    }

    public ResponseEntity<ModelMap> find(RequestPageObj<Map<String, Object>> requestPageObj) {
        setPageHelper(requestPageObj);
        return ResponseUtil.ok(webPointValueTypeMapper.selectByObject(requestPageObj.getData()));
    }

    public List<WebPointValueType> selectByAll() {
        return  webPointValueTypeMapper.selectByObject(null);
    }

    public ResponseEntity<ModelMap> insert(WebPointValueType webPointValueType) {
        String id = ToolUtils.generateUUID32();
        webPointValueType.setId(id);
        webPointValueTypeMapper.insert(webPointValueType);
        return ResponseUtil.ok(webPointValueType);
    }

    public ResponseEntity<ModelMap> updateById(WebPointValueType webPointValueType) {
        webPointValueTypeMapper.updateById(webPointValueType);
        return ResponseUtil.ok();
    }

    public ResponseEntity<ModelMap> deleteById(String id) {
        webPointValueTypeMapper.deleteById(id);
        return ResponseUtil.ok();
    }

}
